#include "boxing.h"
u16 zhongjian;
u16 Sine12bit2[1001] = {  
	2048,2060,2073,2086,2099,2112,2125,2138,2150,2163,2176,2189,2202,2215,2227,2240,2253,2266,2279,
	2291,2304,2317,2330,2342,2355,2368,2381,2393,2406,2419,2431,2444,2457,2469,2482,2494,2507,2519,
	2532,2544,2557,2569,2582,2594,2607,2619,2631,2644,2656,2668,2680,2693,2705,2717,2729,2741,2753,
	2765,2777,2789,2801,2813,2825,2837,2849,2861,2873,2884,2896,2908,2919,2931,2943,2954,2966,2977,
	2989,3000,3012,3023,3034,3045,3057,3068,3079,3090,3101,3112,3123,3134,3145,3156,3167,3177,3188,
	3199,3209,3220,3230,3241,3251,3262,3272,3282,3293,3303,3313,3323,3333,3343,3353,3363,3373,3382,
	3392,3402,3411,3421,3431,3440,3449,3459,3468,3477,3487,3496,3505,3514,3523,3532,3540,3549,3558,
	3567,3575,3584,3592,3601,3609,3617,3626,3634,3642,3650,3658,3666,3674,3681,3689,3697,3704,3712,
	3719,3727,3734,3741,3749,3756,3763,3770,3777,3784,3790,3797,3804,3810,3817,3823,3830,3836,3842,
	3848,3854,3860,3866,3872,3878,3884,3889,3895,3901,3906,3911,3917,3922,3927,3932,3937,3942,3947,
	3952,3956,3961,3966,3970,3974,3979,3983,3987,3991,3995,3999,4003,4007,4011,4014,4018,4021,4025,
	4028,4031,4034,4037,4040,4043,4046,4049,4052,4054,4057,4059,4062,4064,4066,4068,4070,4072,4074,
	4076,4078,4079,4081,4082,4084,4085,4086,4088,4089,4090,4091,4091,4092,4093,4094,4094,4094,4095,
	4095,4095,4095,4096,4095,4095,4095,4095,4094,4094,4094,4093,4092,4091,4091,4090,4089,4088,4086,
	4085,4084,4082,4081,4079,4078,4076,4074,4072,4070,4068,4066,4064,4062,4059,4057,4054,4052,4049,
	4046,4043,4040,4037,4034,4031,4028,4025,4021,4018,4014,4011,4007,4003,3999,3995,3991,3987,3983,
	3979,3974,3970,3966,3961,3956,3952,3947,3942,3937,3932,3927,3922,3917,3911,3906,3901,3895,3889,
	3884,3878,3872,3866,3860,3854,3848,3842,3836,3830,3823,3817,3810,3804,3797,3790,3784,3777,3770,
	3763,3756,3749,3741,3734,3727,3719,3712,3704,3697,3689,3681,3674,3666,3658,3650,3642,3634,3626,
	3617,3609,3601,3592,3584,3575,3567,3558,3549,3540,3532,3523,3514,3505,3496,3487,3477,3468,3459,
	3449,3440,3431,3421,3411,3402,3392,3382,3373,3363,3353,3343,3333,3323,3313,3303,3293,3282,3272,
	3262,3251,3241,3230,3220,3209,3199,3188,3177,3167,3156,3145,3134,3123,3112,3101,3090,3079,3068,
	3057,3045,3034,3023,3012,3000,2989,2977,2966,2954,2943,2931,2919,2908,2896,2884,2873,2861,2849,
	2837,2825,2813,2801,2789,2777,2765,2753,2741,2729,2717,2705,2693,2680,2668,2656,2644,2631,2619,
	2607,2594,2582,2569,2557,2544,2532,2519,2507,2494,2482,2469,2457,2444,2431,2419,2406,2393,2381,
	2368,2355,2342,2330,2317,2304,2291,2279,2266,2253,2240,2227,2215,2202,2189,2176,2163,2150,2138,
	2125,2112,2099,2086,2073,2060,2048,2035,2022,2009,1996,1983,1970,1957,1945,1932,1919,1906,1893,
	1880,1868,1855,1842,1829,1816,1804,1791,1778,1765,1753,1740,1727,1714,1702,1689,1676,1664,1651,
	1638,1626,1613,1601,1588,1576,1563,1551,1538,1526,1513,1501,1488,1476,1464,1451,1439,1427,1415,
	1402,1390,1378,1366,1354,1342,1330,1318,1306,1294,1282,1270,1258,1246,1234,1222,1211,1199,1187,
	1176,1164,1152,1141,1129,1118,1106,1095,1083,1072,1061,1050,1038,1027,1016,1005,994,983,972,961,
	950,939,928,918,907,896,886,875,865,854,844,833,823,813,802,792,782,772,762,752,742,732,722,713,
	703,693,684,674,664,655,646,636,627,618,608,599,590,581,572,563,555,546,537,528,520,511,503,494,
	486,478,469,461,453,445,437,429,421,414,406,398,391,383,376,368,361,354,346,339,332,325,318,311,
	305,298,291,285,278,272,265,259,253,247,241,235,229,223,217,211,206,200,194,189,184,178,173,168,
	163,158,153,148,143,139,134,129,125,121,116,112,108,104,100,96,92,88,84,81,77,74,70,67,64,61,58,
	55,52,49,46,43,41,38,36,33,31,29,27,25,23,21,19,17,16,14,13,11,10,9,7,6,5,4,4,3,2,1,1,1,0,0,0,0,
	0,0,0,0,0,1,1,1,2,3,4,4,5,6,7,9,10,11,13,14,16,17,19,21,23,25,27,29,31,33,36,38,41,43,46,49,52,
	55,58,61,64,67,70,74,77,81,84,88,92,96,100,104,108,112,116,121,125,129,134,139,143,148,153,158,
	163,168,173,178,184,189,194,200,206,211,217,223,229,235,241,247,253,259,265,272,278,285,291,298,
	305,311,318,325,332,339,346,354,361,368,376,383,391,398,406,414,421,429,437,445,453,461,469,478,
	486,494,503,511,520,528,537,546,555,563,572,581,590,599,608,618,627,636,646,655,664,674,684,693,
	703,713,722,732,742,752,762,772,782,792,802,813,823,833,844,854,865,875,886,896,907,918,928,939,
	950,961,972,983,994,1005,1016,1027,1038,1050,1061,1072,1083,1095,1106,1118,1129,1141,1152,1164,
	1176,1187,1199,1211,1222,1234,1246,1258,1270,1282,1294,1306,1318,1330,1342,1354,1366,1378,1390,
	1402,1415,1427,1439,1451,1464,1476,1488,1501,1513,1526,1538,1551,1563,1576,1588,1601,1613,1626,
	1638,1651,1664,1676,1689,1702,1714,1727,1740,1753,1765,1778,1791,1804,1816,1829,1842,1855,1868,
	1880,1893,1906,1919,1932,1945,1957,1970,1983,1996,2009,2022,2035,2047};
void Dacl_sin(u16 t,u16 f)
{
	double  zhi;
	zhi=Sine12bit2[t*f];
	DAC_SetChannel1Data(DAC_Align_12b_R,zhi);
}

void Dacl_fangbo(u16 t,u16 f)
{
	u16 zhi;
	zhi=sin(t*3.14*0.001*f)+1;
	zhi=zhi*3299;
	Dac1_Set_Vol(zhi);
}

void Dacl_sanjiaobo(u16 t,u16 f)
{
	u16 zhi,tt;
	tt=t;
	if(t<=51)zhongjian =50;
	t-=zhongjian;
	zhi=t*f*20;
	if(zhi>=3299)
	{
		zhi=3299;
		zhongjian=tt;
		
	}
	
	Dac1_Set_Vol(zhi);
}




